home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / comm / maxs / MaxRexx.lha / MAXREXX / Examples / Piggy.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1980-03-10  |  11.3 KB  |  386 lines

  1.  /* Thanks to Kevin Sherman for allowing me to include
  2.     this door in the MaxRexx distribution
  3.     If you have any doors that you would like included
  4.     please feel free to E-mail Ian Chapman. See MaxRexx
  5.     docs.
  6.  
  7.     Original version by Basil
  8.     MaxRexx conversion by Kevin Sherman
  9.  
  10.     Minimum MaxRexx Version: 1.2
  11. */
  12.  line=arg(1)
  13.  port='ADDRESS MAXSERVE'line
  14.  Interpret port
  15.  OPTIONS RESULTS
  16.  IF ~SHOW(l,'rexxsupport.library') THEN CALL ADDLIB('rexxsupport.library',0,-30,0)
  17.  IF ~SHOW(l,'rexxarplib.library') THEN CALL ADDLIB('rexxarplib.library',0,-30,0)
  18.  START:
  19.  
  20.  $CLS
  21.  $PRINTLN "                                Introducing"
  22.  $PRINTLN "                     PIGGY Version 0.1 (MaxsBBS version)"
  23.  $NEWLINE
  24.  $PRINTLN "                             by Kevin Sherman"
  25.  $NEWLINE
  26.  $PRINTLN "                          Original game & concept"
  27.  $PRINTLN "                             by Basil Barnes"
  28.  $NEWLINE
  29.  $PRINTLN "                      A very adictive game of dice."
  30.  $NEWLINE
  31.  $NEWLINE
  32.  $PRINT "Continue, quit, or help? Enter=C/h/q: "
  33.  $HOTKEY
  34.  answer = UPPER(D2C(RESULT))
  35.  SELECT
  36.    WHEN answer = "C" | c2d(answer) = 13 THEN
  37.      DO
  38.        DROP answer
  39.        COMPUTERTOTAL = 0
  40.        USERTOTAL = 0
  41.        CALL RANDOM(,, TIME(s))
  42.        beginer = RANDOM(1,2)
  43.        IF beginer = 1 THEN
  44.          DO
  45.            $NEWLINE
  46.            $PRINTLN "I'll go first this time."
  47.            firstplayer = COMPUTER
  48.            CALL DELAY(200)
  49.          END
  50.        ELSE
  51.          DO
  52.            $NEWLINE
  53.            $PRINTLN "You go first this time."
  54.            firstplayer = USER
  55.            CALL DELAY(200)
  56.          END
  57.        esc = x2c('1B')
  58.        player = firstplayer
  59.        quote.1 = "Come on, baby needs a new pair of shoes!"
  60.        quote.2 = "And the dice say....."
  61.        quote.3 = "One more time with fealing."
  62.        quote.4 = "Hay, are these dice loaded!?!?!"
  63.        quote.5 = "Ooooohhhhhh, I'm HOT tonight!"
  64.        quote.6 = "Come on baby give be those boxcars!"
  65.        quote.7 = "Gotta be cool now, gotta take care...."
  66.        quote.8 = "Think positive thoughts. The dice are my friend. The dice are my..."
  67.        quote.9 = "And there coming out of there shoot...."
  68.        quote.10 = "Look out there hot stuff coming through...."
  69.        quote.11 = "Please GOD give me a good roll and I'll never ask for anything again."
  70.        quote.12 = "Rattle, rattle, rattle and the dice say...."
  71.        quote.13 = "You sure your not cheating?"
  72.        quote.14 = "Come on, come on... Looking for that hot streak!"
  73.        quote.15 = "Like shooting fish in a pond."
  74.        quote.16 = "Oooh, maybe I should't roll this time."
  75.        quote.17 = "Fealing lucky punk? Well do you?!"
  76.        quote.18 = "Is it hot in here or is it just the dice?"
  77.        quote.19 = "What were the rules again?"
  78.        quote.20 = "OK, just one more time."
  79.        DO FOREVER
  80.          IF player = "COMPUTER" THEN CALL computerroll
  81.          IF player = "USER" THEN  CALL userroll
  82.        END
  83.      END
  84.    WHEN answer = "H" THEN
  85.      DO
  86.        DROP answer
  87.        $CLS
  88.        $PRINTLN "The object of the game is to be the first one to reach 150 points by adding"
  89.        $PRINTLN "the roll of the dice together.  But beware the player that is second always"
  90.        $PRINTLN "has the last roll."
  91.        $NEWLINE
  92.        $PRINT "Enter to continue. "
  93.        $HOTKEY
  94.        CALL START
  95.      END
  96.    WHEN answer = "Q" THEN
  97.      DO
  98.        $END
  99.        EXIT
  100.      END
  101.    OTHERWISE CALL START
  102.  END
  103.  
  104.  COMPUTERROLL:
  105.  
  106.  IF USERTOTAL >= 150 & firstplayer = "COMPUTER" THEN CALL game_end
  107.  IF COMPUTERTOTAL >= 150 & firstplayer = "USER" THEN CALL game_end
  108.  rolltotal = 0
  109.  DO x = 1 TO RANDOM(2,10)
  110.    IF USERTOTAL < 150 THEN
  111.      DO
  112.        call show_dice
  113.        SELECT
  114.          WHEN roll = 2 THEN
  115.            DO
  116.              $PRINTLN "Drat!! I rolled snake eyes I start back at 0"
  117.              COMPUTERTOTAL = 0
  118.              player = user
  119.              CALL DELAY(200)
  120.              RETURN
  121.            END
  122.          WHEN dice.1 = 1 | dice.2 = 1 THEN
  123.            DO
  124.              $PRINTLN "I rolled a one. My turn is over."
  125.              player = user
  126.              CALL DELAY(200)
  127.              RETURN
  128.            END
  129.          WHEN COMPUTERTOTAL + rolltotal > 150 & firstplayer = "USER" THEN
  130.            DO
  131.              COMPUTERTOTAL = COMPUTERTOTAL + rolltotal
  132.              CALL DELAY(200)
  133.              CALL game_end
  134.            END
  135.          OTHERWISE CALL DELAY(100)
  136.        END
  137.      END
  138.    ELSE
  139.      DO WHILE COMPUTERTOTAL + rolltotal < USERTOTAL
  140.        CALL show_dice
  141.        SELECT
  142.          WHEN roll = 2 THEN
  143.            DO
  144.              COMPUTERTOTAL = 0
  145.              $PRINTLN "Ahhhh!! I rolled snake eyes!! I lost big time. You lucky stiff."
  146.              CALL DELAY(100)
  147.              CALL game_end
  148.            END
  149.          WHEN dice.1 = 1 | dice.2 = 1 THEN
  150.            DO
  151.              $PRINTLN "Not Now! Not a ONE! Ahhhhh. You beat me."
  152.              CALL DELAY(100)
  153.              CALL game_end
  154.            END
  155.          WHEN COMPUTERTOTAL + rolltotal > playertotal THEN
  156.            DO
  157.              COMPUTERTOTAL = COMPUTERTOTAL + rolltotal
  158.              $PRINTLN "Hehehehe. Your not piggy enough, I won!"
  159.              CALL DELAY(100)
  160.              CALL game_end
  161.            END
  162.          OTHERWISE CALL DELAY(100)
  163.        END
  164.      END
  165.  END
  166.  COMPUTERTOTAL = rolltotal + COMPUTERTOTAL
  167.  IF COMPUTERTOTAL >= 150 THEN
  168.    DO
  169.      $PRINTLN "OK, it's do or die time for you now!"
  170.      player = user
  171.      CALL DELAY(200)
  172.      RETURN
  173.    END
  174.  $PRINTLN "That's it for me this time."
  175.  player = user
  176.  CALL DELAY(200)
  177.  RETURN
  178.  
  179.  USERROLL:
  180.  
  181.  rolltotal = 0
  182.  $CLS
  183.  $PRINTLN "Game Totals: Computer:" COMPUTERTOTAL "      You:" USERTOTAL "   First player was" firstplayer
  184.  $NEWLINE
  185.  $PRINT "Would you like to roll the dice? Enter=Y/n/q: "
  186.  $HOTKEY
  187.  DO FOREVER
  188.    answer = UPPER(D2C(RESULT))
  189.    SELECT
  190.      WHEN answer = "N" THEN
  191.        DO
  192.          DROP answer
  193.          USERTOTAL = rolltotal + USERTOTAL
  194.          IF USERTOTAL >= 150 & firstplayer = "COMPUTER" THEN CALL game_end
  195.          SELECT
  196.            WHEN COMPUTERTOTAL >= 150 THEN
  197.              DO
  198.                IF COMPUTERTOTAL > USERTOTAL THEN $PRINTLN "Giving up are you? Good choice, sucker."
  199.                CALL DELAY(200)
  200.                CALL game_end
  201.              END
  202.            WHEN USERTOTAL >= 150 THEN
  203.              DO
  204.                $PRINTLN "YIPES! It's do or die time now!"
  205.                player = computer
  206.                CALL DELAY(200)
  207.                RETURN
  208.              END
  209.            OTHERWISE player = computer
  210.          END
  211.          RETURN
  212.        END
  213.      WHEN answer = "Q" THEN
  214.        DO
  215.          DROP answer
  216.          $NEWLINE
  217.          $PRINTLN "Chicken, try and play again when you have more guts."
  218.          CALL DELAY(300)
  219.          $END
  220.          EXIT
  221.        END
  222.      WHEN answer = "Y" | RESULT = 13 THEN
  223.        DO
  224.          DROP answer
  225.          call show_dice
  226.          SELECT
  227.            WHEN roll = 2 THEN
  228.              DO
  229.                $PRINTLN "Tough break, you rolled snake eyes you start back at 0."
  230.                USERTOTAL = 0
  231.                IF COMPUTERTOTAL > 150 THEN
  232.                  DO
  233.                    $PRINTLN "Hehehehe, that roll couldn't have come at a worse time."
  234.                    $PRINTLN "Man I beat you bad! You shouldn't have been so PIGGY."
  235.                    CALL DELAY(200)
  236.                    CALL game_end
  237.                  END
  238.                player = computer
  239.                CALL DELAY(200)
  240.                RETURN
  241.              END
  242.            WHEN dice.1 = 1 | dice.2 = 1 THEN
  243.              DO
  244.                IF COMPUTERTOTAL > 150 THEN
  245.                  DO
  246.                    $PRINTLN "Aaawwww, such bad luck. Well that is what you get for being so PIGGY."
  247.                    CALL DELAY(200)
  248.                    CALL game_end
  249.                  END
  250.                $PRINTLN "You rolled a one, my turn now."
  251.                player = computer
  252.                CALL DELAY(200)
  253.                RETURN
  254.              END
  255.            OTHERWISE NOP
  256.          END
  257.        END
  258.      OTHERWISE
  259.        DO
  260.          $CLS
  261.          $PRINTLN "Game Totals: Computer:" COMPUTERTOTAL "      You:" USERTOTAL "    First player was" firstplayer
  262.          $NEWLINE
  263.          $PRINT "*"answer"* Is not one of the options, roll the dice? Enter=Y/n/q: "
  264.          $HOTKEY
  265.          ITERATE
  266.        END
  267.    END
  268.  $PRINT "Want to roll again? Enter=Y/n/q: "
  269.  $HOTKEY
  270.  END
  271.  
  272.  SHOW_DICE:
  273.  CALL RANDOM(,, TIME(s))
  274.  dice.1 = RANDOM(1, 6)
  275.  dice.2 = RANDOM(1, 6)
  276.  roll = dice.1 + dice.2
  277.  rolltotal = roll + rolltotal
  278.  $CLS
  279.  $PRINTLN "Game Totals: Computer:" COMPUTERTOTAL "      You:" USERTOTAL "    First player was" firstplayer
  280.  $NEWLINE
  281.  CALL RANDOM(,, TIME(s))
  282.  q = RANDOM(1,20)
  283.  $PRINTLN quote.q
  284.  $NEWLINE
  285.  dicepos1 = random(1,40,time(s))
  286.  dicepos2 = random(dicepos1 + 7,75,time(s))
  287.  $FCOLOUR 0
  288.  $BCOLOUR 7
  289.  $PRINTLN esc"[6;"dicepos1"H     "esc"[6;"dicepos2"H     "
  290.  $PRINTLN esc"[7;"dicepos1"H     "esc"[7;"dicepos2"H     "
  291.  $PRINTLN esc"[8;"dicepos1"H     "esc"[8;"dicepos2"H     "
  292.  SELECT
  293.    WHEN dice.1 = 1 THEN $PRINTLN esc"[7;"dicepos1 + 2"H*"
  294.    WHEN dice.1 = 2 THEN
  295.      DO
  296.        $PRINTLN esc"[6;"dicepos1"H*"
  297.        $PRINTLN esc"[8;"dicepos1 + 4"H*"
  298.      END
  299.    WHEN dice.1 = 3 THEN
  300.      DO
  301.        $PRINTLN esc"[6;"dicepos1"H*"
  302.        $PRINTLN esc"[7;"dicepos1 + 2"H*"
  303.        $PRINTLN esc"[8;"dicepos1 + 4"H*"
  304.      END
  305.    WHEN dice.1 = 4 THEN
  306.      DO
  307.        $PRINTLN esc"[6;"dicepos1"H*"esc"[6;"dicepos1 + 4"H*"
  308.        $PRINTLN esc"[8;"dicepos1"H*"esc"[8;"dicepos1 + 4"H*"
  309.      END
  310.    WHEN dice.1 = 5 THEN
  311.      DO
  312.        $PRINTLN esc"[6;"dicepos1"H*"esc"[6;"dicepos1 + 4"H*"
  313.        $PRINTLN esc"[7;"dicepos1 + 2"H*"
  314.        $PRINTLN esc"[8;"dicepos1"H*"esc"[8;"dicepos1 + 4"H*"
  315.      END
  316.    WHEN dice.1 = 6 THEN
  317.      DO
  318.        $PRINTLN esc"[6;"dicepos1"H*"esc"[6;"dicepos1 + 4"H*"
  319.        $PRINTLN esc"[7;"dicepos1"H*"esc"[7;"dicepos1 + 4"H*"
  320.        $PRINTLN esc"[8;"dicepos1"H*"esc"[8;"dicepos1 + 4"H*"
  321.      END
  322.  END
  323.  SELECT
  324.    WHEN dice.2 = 1 THEN $PRINTLN esc"[7;"dicepos2 + 2"H*"
  325.    WHEN dice.2 = 2 THEN
  326.      DO
  327.        $PRINTLN esc"[6;"dicepos2"H*"
  328.        $PRINTLN esc"[8;"dicepos2 + 4"H*"
  329.      END
  330.    WHEN dice.2 = 3 THEN
  331.      DO
  332.        $PRINTLN esc"[6;"dicepos2"H*"
  333.        $PRINTLN esc"[7;"dicepos2 + 2"H*"
  334.        $PRINTLN esc"[8;"dicepos2 + 4"H*"
  335.      END
  336.    WHEN dice.2 = 4 THEN
  337.      DO
  338.        $PRINTLN esc"[6;"dicepos2"H*"esc"[6;"dicepos2 + 4"H*"
  339.        $PRINTLN esc"[8;"dicepos2"H*"esc"[8;"dicepos2 + 4"H*"
  340.      END
  341.    WHEN dice.2 = 5 THEN
  342.      DO
  343.        $PRINTLN esc"[6;"dicepos2"H*"esc"[6;"dicepos2 + 4"H*"
  344.        $PRINTLN esc"[7;"dicepos2 + 2"H*"
  345.        $PRINTLN esc"[8;"dicepos2"H*"esc"[8;"dicepos2 + 4"H*"
  346.      END
  347.    WHEN dice.2 = 6 THEN
  348.      DO
  349.        $PRINTLN esc"[6;"dicepos2"H*"esc"[6;"dicepos2 + 4"H*"
  350.        $PRINTLN esc"[7;"dicepos2"H*"esc"[7;"dicepos2 + 4"H*"
  351.        $PRINTLN esc"[8;"dicepos2"H*"esc"[8;"dicepos2 + 4"H*"
  352.      END
  353.  END
  354.  $FCOLOUR 7
  355.  $BCOLOUR 0
  356.  IF Player = "COMPUTER" THEN
  357.  $PRINTLN esc"[10;1HThe roll was:" dice.1 dice.2 "Current total:" COMPUTERTOTAL + rolltotal
  358.  ELSE
  359.  $PRINTLN esc"[10;1HThe roll was:" dice.1 dice.2 "Current total:" USERTOTAL + rolltotal
  360.  RETURN
  361.  
  362.  GAME_END:
  363.  
  364.  $CLS
  365.  $PRINTLN "Game Totals: Computer:" COMPUTERTOTAL "      You:" USERTOTAL "  First player was" firstplayer
  366.  $NEWLINE
  367.  $PRINTLN "                 We have a winner... and the winner is...."
  368.  $NEWLINE
  369.  CALL DELAY(100)
  370.  IF COMPUTERTOTAL > USERTOTAL THEN
  371.    DO
  372.      $PRINTLN "                             THE COMPUTER!!!!"
  373.      $PRINTLN "Better luck next time."
  374.      CALL DELAY(300)
  375.      $END
  376.      EXIT
  377.    END
  378.  ELSE
  379.    DO
  380.      $PRINTLN "YOU!!!!"
  381.      $PRINTLN "Job well done."
  382.      CALL DELAY(300)
  383.      $END
  384.      EXIT
  385.    END
  386.